package com.sikaryofficial.system.api;

import com.sikaryofficial.common.core.constant.SecurityConstants;
import com.sikaryofficial.common.core.constant.ServiceNameConstants;
import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.domain.SysUser;
import com.sikaryofficial.system.api.domain.UserReq;
import com.sikaryofficial.system.api.factory.RemoteUserFallbackFactory;
import com.sikaryofficial.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * 用户服务
 * 
 * @author qinjinyuan
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户名查询用户信息
     *
     * @return 结果
     */
    @GetMapping("/user/getInfoByh5")
    R<SysUser> getInfoByh5();

    /**
     * 通过用户名查询用户信息
     *
     * @param userId 用户名
     * @return 结果
     */
    @GetMapping("/user/getUserByUserId/{userId}")
    R<SysUser> getUserByUserId(@PathVariable("userId") Long userId);

    /**
     * 通过邮箱地址查询用户账户
     *
     * @param email 邮箱地址
     * @return 结果
     */
    @GetMapping("/user/infoByEmail/{email}")
    R<String> getUserNameByEmail(@PathVariable("email") String email);
    /**
     * 获取账户名
     * @param uuid
     * @return
     */
    @GetMapping("/user/infoByUuid/{uuid}")
    R<String> getUserNameByUuid(@PathVariable("uuid") String uuid);
    /**
     * 邮箱唯一性校验
     * @param email
     * @return
     */
    @GetMapping("/user/checkEmailUnique/{email}")
    R<Boolean> checkEmailUnique(@PathVariable("email") String email);
    /**
     * 删除用户账户
     *
     * @param userIds 用户ID集合
     * @return 结果
     */
    @DeleteMapping("/user/deleteUserByOwner/{userIds}")
    R<Integer> deleteUserByOwner(@PathVariable("userIds") Long[] userIds);

    /**
     * 删除会员账户
     * @param userIds
     * @return
     */
    @DeleteMapping("/user/deleteMemberUsers/{userIds}")
    R<Integer> deleteMemberUsers(@PathVariable("userIds") Long[] userIds);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/registerByH5")
    R<Boolean> registerUserByH5(@RequestBody UserReq req,  @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/registerForChannel")
    R<Long> registerForChannel(@RequestBody SysUser sysUser,  @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 初始化H5用户角色和岗位
     *
     * @param user 用户ID集合
     * @return 结果
     */
    @PutMapping("/user/initH5UserRoleAndPost")
    R<Integer> initH5UserRoleAndPost(@RequestBody SysUser user);

    /**
     * 初始化H5用户角色和岗位
     *
     * @param userId 用户ID
     * @return 结果
     */
    @GetMapping("/user/userCache/{userId}")
    R<SysUser> getSysUserInfoCacheById(@PathVariable("userId") Long userId);

}
